<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="header.jsp" %>
<%--
  Created by IntelliJ IDEA.
  User: 77869
  Date: 2022/11/18
  Time: 13:04
  To change this template use File | Settings | File Templates.
--%>

<html>
<head>

    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="static/login.css">
    <title>Document</title>

    <script type="text/javascript">
        let alert_msg = '${alert_msg}';
        if (alert_msg != null && alert_msg.trim() != '') {
            window.alert(alert_msg);
        }
    </script>
</head>

<body>

<form id="formId" class="login" method="post" onsubmit="return check()">
    <p>Login</p>
    <input type="text" name="username" placeholder="用户名">
    <input type="password" name="password" placeholder="密码">
    <input type="button" class="btn" value="登  录" onclick="submitForm()">
</form>
</body>
<script type="text/javascript">
    function submitForm() {
        $.post(
            '${path}/user?method=login',
            $('#formId').serialize(),
            function (jsonObj) {
                console.log(jsonObj);
                if (jsonObj.isOk == false) {
                    layer.msg("用户名或密码错误");
                } else {
                    location.href = '${path}/';
                }
            },
            'json'
        );
    }
</script>


</html>
